package homework.day3;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = input.next();
        System.out.println("请输入密码：");
        String pwd = input.next();
        System.out.println("请输入用户名：");
        String nick = input.next();
        System.out.println("请输入年龄：");
        int age = input.nextInt();

        User user = new User(name,pwd,nick,age);

        FileOutputStream fos = new FileOutputStream(name+".obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);

        oos.writeObject(user);
        System.out.println("写出完毕");
        oos.close();
    }
}
